package lib

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Response struct {
	Code  int         `json:"code"`
	Count int         `json:"count"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data"`
}

func Result(code int, count int, data interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, Response{
		Code:  code,
		Count: count,
		Data:  data,
		Msg:   msg,
	})
}

func WithMessage(code int, message string, c *gin.Context) {
	Result(code, 0, map[string]interface{}{}, message, c)
}
